#ifndef LISTBOX_H_
#define LISTBOX_H_

#include <aknsdrawutils.h>
#include <aknscontrolcontext.h>
#include <AknsSkinInstance.h>
#include <aknsutils.h>
#include <eiksbfrm.h>

#include "BaseControl.h"
#include "ListItem.h"
#include "Image.h"
#include "ScrollBarObserver.h"

class CListBox : public CBaseControl,MCustomScrollBarObserver
{
public:
	static CListBox* NewL(const TRect& aRect, const CCoeControl* aParent);
	static CListBox* NewLC(const TRect& aRect, const CCoeControl* aParent);
	virtual ~CListBox();
protected:
	CListBox();
	void ConstructL(const TRect& aRect, const CCoeControl* aParent);
public:
	// from base class CCoeControl
	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
public: // own methods
    // NOTE: Transfer ownership to CContainerControl
    void AddListItemL(CListItem* aControl);
    void RemoveItem(CListItem* aControl);
    void RemoveAllItems();
    TInt Count();
    virtual void UpdateControls(TInt aOffset = 0);
    virtual void UpdateScrollBarFrameL();
    TBool IsInRect(CCoeControl* aCtrl);
    TBool IsInRect(TPoint aLTPt,CCoeControl* aCtrl);
	//����б����õ�ͼ��
	void AddBitmap(CImage* aImage);
	CImage* GetBitmap(TInt aIndex);
	TInt GetBitmapCount();
	virtual void SetCurrentItemIndex(TInt aIndex);
	TInt CurrentItemIndex();
	CCoeControl* FocusedItem();
	CCoeControl* GetItem(TInt aIndex);
	void SetDrawLine(TBool aDrawLine);
	void SetSelItemBackGroundBitmapL(CImage* aImage);
	CImage* SelItemBackGroundBitmap() const;
	TInt FirstControlOffY();
	
public://from MCustomScrollBarObserver
	 void ChangeRectsCoordinates(TInt aNewPosition);
	
private:
	virtual void Draw(const TRect& aRect) const;
    virtual void SizeChanged(const TRect& aRect);
    void FocusChanged(TDrawNow aDrawNow);
private:
	void AddIconL(CImage* aImage);
    TBool MoveFocusUpL();
    TBool MoveFocusDownL();
    
protected:
    TInt                                iFocusedIndex;
    TInt 								iMaxControlIndex;
    CCoeControl* 						iFocusControl;
    RPointerArray<CImage> 			    iIconList;
    CImage*                             iSelItemBgBitmap;//ѡ���б���ͼƬ
    CEikScrollBarFrame*                 iScrollBarFrame;
    TAknDoubleSpanScrollBarModel        iHDsSbarModel;
    TAknDoubleSpanScrollBarModel        iVDsSbarModel;
    TInt                                iTotalHeight; // Height of the controls
    TBool                               iHasSizeChange;
	TBool iDrawLine;
	RArray<TPoint> iLinePoint;
	CCoeControl* iFirstControl;
	TInt iFirstPositionY;
	CScrollBarObserver* iScrollBarObserver;
};

#endif /*LISTBOX_H_*/
